Set ANSI_NULLS ON
Set QUOTED_IDENTIFIER ON
GO

/*Drop stored procedures if they exists */

IF EXISTS (SELECT name FROM sysobjects WHERE name = 'verificarNombreTipoMaterial' and type = 'P')

	BEGIN
		DROP PROCEDURE verificarNombreTipoMaterial
	END

GO

CREATE PROCEDURE verificarNombreTipoMaterial ( @nombreTipoMaterial VARCHAR (40) ,
												@unidadMedida INT,
												@outParam INT OUTPUT						
										)
AS

	DECLARE @out AS INT;
	SET @out = -1;
	
	SELECT @out = TIPO_MATERIAL.IDTIPOMATERIAL 
	FROM TIPO_MATERIAL
	WHERE TIPO_MATERIAL.NOMBRETIPOMATERIAL = @nombreTipoMaterial
	AND TIPO_MATERIAL.IDUNIDADDEMEDIDA = @unidadMedida;	 
	
	SET @outParam = @out;

	SELECT @outParam;
GO